package com.lhn.bbs.dao;

import java.nio.file.Paths;
import java.util.List;
import java.util.Map;

import com.lhn.bbs.utils.JiebaUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import com.huaban.analysis.jieba.JiebaSegmenter;
import com.huaban.analysis.jieba.WordDictionary;
import junit.framework.TestCase;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;


@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class jiebatexts extends TestCase {


    /*    private JiebaSegmenter segmenter = new JiebaSegmenter();
        String sentences = "北京京天威科技发展有限公司大庆车务段的装车数量";

        *//**
         * 读取conf目录下所有的自定义词库**.dict文件。
         *//*
        @Override
        protected void setUp() throws Exception {
            WordDictionary.getInstance().init(Paths.get("conf"));
        }

        @Test
        public void testCutForSearch() {
            System.out.println(segmenter.sentenceProcess(sentences));
        }*/

    @Autowired
    private JiebaUtils jiebaUtils ;

    @Test
    public void jiebatext() {

         String s = "这是对2主题的回复帖在这里畅所欲言你的看法吧在这里畅所欲言你的看法吧在这里畅所欲言你的看法吧在这里畅所欲言你的看法吧说说你的看法我无话可说敏感词有,***,***,***等跪求offer......\n" +
                 "好消息这次好了吧，垃圾多发评论会产生高频词提取哦多发评论会产生高频词提取哦多发评论会产生高频词提取哦多发评论会产生高频词提取哦多发评论会产生高频词提取哦";
            List<String> fenci = jiebaUtils.fenci(s);

            System.out.print(fenci.toString());

            Map<String, Integer> tiqugaopinci = jiebaUtils.tiqugaopinci(fenci);

//            Map<String, Integer> gaopincixianshi = jiebaUtils.gaopincixianshi(tiqugaopinci);

            for(String key : tiqugaopinci.keySet()){
                    Integer count = tiqugaopinci.get(key);

            System.out.println("Key = " + key + ", Value = " + count);
            }
    }

    @Test
    public void higeword() {
        String higeword = jiebaUtils.higeword("这是对2主题的回复帖在这里畅所欲言你的看法吧在这里畅所欲言你的看法吧在这里畅所欲言你的看法吧在这里畅所欲言你的看法吧说说你的看法我无话可说敏感词有,***,***,***等跪求offer......\n" +
                "好消息这次好了吧***\n" +
                "垃圾多发评论会产生高频词提取哦多发评论会产生高频词提取哦多发评论会产生高频词提取哦多发评论会产生高频词提取哦多发评论会产生高频词提取哦");

        System.out.print("高频词:"+higeword);

    }

}
